using System;
using Provausio.Common.Objects;
using TrainingManagement.api.Models.Data.CRUD;
using TrainingManagement.api.Models.Data.CRUD.TrainingRecord;

namespace TrainingManagement.api.Models.BusinessLogic.TrainingRecord
{
    public class TrainingRecordCompletePendingOperation : BusinessOperation<BusinessObjects.TrainingRecord, bool>
    {
        readonly TrainingRecordCompletePendingDataSource _completePending = new TrainingRecordCompletePendingDataSource();

        public override bool Run(BusinessObjects.TrainingRecord input)
        {
            if (_completePending.Execute(input))
                return true;
            throw new Exception("Failed to update record!");
        }
    }
}